<?php

namespace App\Http\Controllers;

use App\Model\Version;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

//主页
class InviteController extends Controller
{
    //邀请
    public function invite(){
        $invite = request()->invite;

        return view('invite.phone',compact('invite'));
    }

    //邮箱注册页
    public function email(){
         $invite = request()->invite;

        return view('invite.mailbox',compact('invite'));
    }

    //手机注册页
    public function phone(){
         $invite = request()->invite;

        return view('invite.phone',compact('invite'));
    }

    //下载
    public function down(){
		$iosUrl = './';
		$andUrl = './';

		// 获取最新版本的IOS地址
		$ver1 = Version::latest('id')->where('type', 2)->first();
		if($ver1){
            // $iosUrl = 'itms-services://?action=download-manifest&url=' . $ver1->file_url;
            $iosUrl = 'https://apps.apple.com/us/app/id1523125416';
//			$iosUrl = $ver1->file_url;
		}

		// 获取最新版本的安卓地址
		$ver2 = Version::latest('id')->where('type', 1)->first();
		if($ver2){
			$andUrl = $ver2->file_url;
		}

		$data = [
			'ios_url' => $iosUrl,
			'and_url' => $andUrl,
		];

		return view('invite.down', $data);

    }
}